package testmysql.mysql;

import java.util.List;

import org.nutz.dao.Dao;
import org.nutz.dao.impl.NutDao;
import org.nutz.log.Log;
import org.nutz.log.Logs;

import com.alibaba.druid.pool.DruidDataSource;

@SuppressWarnings("all")
public class DbKit {

	private static final Log logger = Logs.get();
	
	public static Dao dao;

	public static Dao getDao() {
		DruidDataSource ds = new DruidDataSource();
		ds.setUsername("root");
		ds.setPassword("root");
		ds.setUrl("jdbc:mysql://127.0.0.1:3306/db_test?charachterEncoding=UTF-8;");

		if (dao != null) {
			return dao;
		}
		dao = new NutDao(ds);
		return dao;
	}

	public  static List<t_log> listall() {
		logger.debug("查询sql中的数据... ");
		return getDao().query(t_log.class, null);
	}

}
